<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>CloseTab</title>
    <style>
      body {
        width: 400px;
        padding: 8px;
        font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text',
          'SF Pro Icons', 'Helvetica Neue', sans-serif;
        background-color: #f2f2f7;
      }
      .container {
        display: flex;
        flex-direction: column;
        gap: 8px;
      }
      .button-group {
        display: flex;
        flex-direction: column;
        gap: 6px;
      }
      .button-row {
        display: flex;
        gap: 6px;
      }
      .settings-group {
        display: flex;
        flex-direction: column;
        gap: 6px;
        background-color: white;
        padding: 10px;
        border-radius: 10px;
        font-size: 13px;
      }
      button {
        padding: 8px 12px;
        border: none;
        border-radius: 10px;
        background-color: #007aff;
        color: white;
        cursor: pointer;
        font-size: 14px;
        font-weight: 500;
        flex: 1;
        transition: background-color 0.2s ease;
        white-space: nowrap;
      }
      button:hover {
        background-color: #0051a8;
      }
      button:active {
        background-color: #004c99;
        transform: scale(0.98);
      }
      button.small {
        padding: 4px 10px;
        font-size: 13px;
      }
      button.danger {
        background-color: #ff3b30;
      }
      button.danger:hover {
        background-color: #d70015;
      }
      .tab-groups {
        max-height: 360px;
        overflow-y: auto;
        padding: 4px;
      }
      .tab-groups::-webkit-scrollbar {
        width: 8px;
      }
      .tab-groups::-webkit-scrollbar-track {
        background: transparent;
      }
      .tab-groups::-webkit-scrollbar-thumb {
        background: #c7c7cc;
        border-radius: 4px;
      }
      .tab-groups::-webkit-scrollbar-thumb:hover {
        background: #8e8e93;
      }
      .tab-group {
        background-color: white;
        border-radius: 14px;
        margin-bottom: 12px;
        padding: 16px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
      }
      .tab-group-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 8px;
      }
      .tab-group-title {
        font-weight: 600;
        margin: 0;
        font-size: 17px;
        color: #1c1c1e;
      }
      .tab-count {
        color: #8e8e93;
        font-size: 13px;
        margin-top: 2px;
      }
      .tab-group-actions {
        display: flex;
        gap: 8px;
      }
      .tab-group-actions button {
        padding: 4px 12px;
        font-size: 13px;
        background-color: transparent;
        border: 1px solid #007aff;
        color: #007aff;
      }
      .tab-group-actions button:hover {
        background-color: rgba(0, 122, 255, 0.1);
      }
      .tab-group-actions .danger {
        border-color: #ff3b30;
        color: #ff3b30;
      }
      .tab-group-actions .danger:hover {
        background-color: rgba(255, 59, 48, 0.1);
      }
      .tab-list {
        border-top: 1px solid #e5e5ea;
      }
      .tab-item {
        font-size: 15px;
        color: #1c1c1e;
        margin: 0;
        padding: 8px 0;
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 12px;
        border-bottom: 1px solid #e5e5ea;
      }
      .tab-item:last-child {
        border-bottom: none;
      }
      .tab-title {
        flex: 1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }
      .tab-actions {
        display: flex;
        gap: 6px;
      }
      .icon-btn {
        padding: 4px;
        width: 28px;
        height: 28px;
        display: flex;
        align-items: center;
        justify-content: center;
        flex: initial;
        background-color: #007aff !important;
        border-radius: 50%;
      }
      .icon-btn.danger {
        background-color: #ff3b30 !important;
      }
      .icon-btn:hover {
        background-color: #0051a8;
      }
      .icon-btn.danger:hover {
        background-color: #d70015 !important;
      }
      .icon-btn .icon {
        width: 16px;
        height: 16px;
        filter: invert(1);
      }
      .tab-nav {
        display: flex;
        gap: 4px;
        background-color: white;
        padding: 2px;
        border-radius: 10px;
      }
      .tab-nav button {
        padding: 6px 12px;
        background-color: transparent;
        color: #8e8e93;
        font-size: 13px;
        font-weight: 500;
      }
      .tab-nav button.active {
        background-color: #007aff;
        color: white;
      }
      .favorite-btn {
        padding: 4px;
        width: 28px;
        height: 28px;
        background-color: transparent !important;
        border: 1px solid #007aff !important;
      }
      .favorite-btn .icon {
        width: 16px;
        height: 16px;
        filter: invert(40%) sepia(93%) saturate(3832%) hue-rotate(199deg)
          brightness(102%) contrast(107%);
      }
      .favorite-btn.active {
        background-color: #007aff !important;
      }
      .favorite-btn.active .icon {
        filter: invert(1);
      }
      .switch {
        position: relative;
        display: inline-block;
        width: 40px;
        height: 24px;
      }
      .switch input {
        opacity: 0;
        width: 0;
        height: 0;
      }
      .slider {
        position: absolute;
        cursor: pointer;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: #e5e5ea;
        transition: 0.2s;
        border-radius: 24px;
      }
      .slider:before {
        position: absolute;
        content: '';
        height: 20px;
        width: 20px;
        left: 2px;
        bottom: 2px;
        background-color: white;
        transition: 0.2s;
        border-radius: 50%;
      }
      input:checked + .slider {
        background-color: #007aff;
      }
      input:checked + .slider:before {
        transform: translateX(16px);
      }
      .setting-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
      }
      .radio-group {
        display: flex;
        gap: 12px;
      }
      .radio-label {
        display: flex;
        align-items: center;
        gap: 4px;
        cursor: pointer;
      }
      .radio-label input[type='radio'] {
        margin: 0;
      }
    </style>
  </head>
  <body>
    <div class="container">
      <div class="button-group">
        <div class="button-row">
          <button id="closeAndSave">保存标签页</button>
        </div>
        <div class="settings-group">
          <div class="setting-row">
            <span>保存时关闭当前标签页</span>
            <label class="switch">
              <input type="checkbox" id="closeTabsAfterSave" checked />
              <span class="slider"></span>
            </label>
          </div>
          <div class="setting-row">
            <span>保存时打开新标签页</span>
            <label class="switch">
              <input type="checkbox" id="openNewTab" checked />
              <span class="slider"></span>
            </label>
          </div>
          <div class="setting-row">
            <span>关闭标签页时打开</span>
            <div class="radio-group">
              <label class="radio-label">
                <input type="radio" name="openPageType" value="blank" checked />
                <span>空白页</span>
              </label>
              <label class="radio-label">
                <input type="radio" name="openPageType" value="manager" />
                <span>管理页面</span>
              </label>
            </div>
          </div>
        </div>
      </div>
      <div class="tab-nav">
        <button id="recentTab" class="active">最近</button>
        <button id="favoriteTab">收藏</button>
      </div>
      <div id="tabGroups" class="tab-groups">
        <!-- 标签组列表将通过JavaScript动态添加 -->
      </div>
    </div>
    <script type="module" src="popup.js"></script>
  </body>
</html>
